<html>
<head><meta charset="utf-8"><title>Available code lens actions? · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Available.20code.20lens.20actions.3F.html">Available code lens actions?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="202350967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Available%20code%20lens%20actions%3F/near/202350967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Available.20code.20lens.20actions.3F.html#202350967">(Jun 29 2020 at 18:35)</a>:</h4>
<p>Hey! Sorry to ask here, I reckon it might not be the best place, but I think it's better than an issue, as it really isn't one <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span> .</p>
<p>I'm trying to find an example of code that generates a code lens with a <code>applySourceEdit</code> or <code>selectAndApplySourceEdit</code> command, but I can't seem to find a way to get one of those. I browsed through the repo a little and didn't find anything that could help me there, but maybe I wasn't paying enough attention. Can anyone point me to an example or explain a situation in which that code lens would appear?</p>



<a name="202352303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Available%20code%20lens%20actions%3F/near/202352303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Available.20code.20lens.20actions.3F.html#202352303">(Jun 29 2020 at 18:46)</a>:</h4>
<p><code>applySourceEdit</code> and <code>selectAndApplySourceEdit</code> don't exist anymore, they used to be used for code actions but have been replaced by a different protocol extension: <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#snippet-textedit">https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#snippet-textedit</a></p>



<a name="202361541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Available%20code%20lens%20actions%3F/near/202361541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Available.20code.20lens.20actions.3F.html#202361541">(Jun 29 2020 at 20:07)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span>  I see, nice! I'm adding an extension to LanguageClient-neovim and, considering the date of the commits on those files, I should probably account for users not using the latest version of rust-analyzer. Did this action (<code>applySourceChange</code>) apply for for example extract variable actions? I will probably downgrade to a version of rust-analyzer that has them and try them out, is that a proper action to be looking at for this command?</p>



<a name="202365472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Available%20code%20lens%20actions%3F/near/202365472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Available.20code.20lens.20actions.3F.html#202365472">(Jun 29 2020 at 20:43)</a>:</h4>
<p>Yes, but I would not recommend trying to keep compatibility with old versions</p>



<a name="202366509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Available%20code%20lens%20actions%3F/near/202366509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Available.20code.20lens.20actions.3F.html#202366509">(Jun 29 2020 at 20:52)</a>:</h4>
<p>yeah I might just abandon that idea, it does feel like I'll end up in a slippery slope of having to maintain all version of all servers anyways, so yeah, probably not a good idea. Thanks for the help! <span aria-label="bow" class="emoji emoji-1f647" role="img" title="bow">:bow:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>